package com.example.interdemo618lw;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.net.Uri;
import android.net.UrlQuerySanitizer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MainActivity extends AppCompatActivity {

    private EditText etpara,eturl,ettel;
    private Button btnxianshi,btnyinshi,btndail;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        intiViews();
    }

    private void intiViews() {
        etpara=findViewById(R.id.editText);
        eturl=findViewById(R.id.editText2);
        ettel=findViewById(R.id.editText3);
        btnxianshi=findViewById(R.id.button);
        btnyinshi=findViewById(R.id.button2);
        btndail=findViewById(R.id.button3);
        btnxianshi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(MainActivity.this,Main2Activity.class);
                intent.putExtra("info",etpara.getText().toString());
                intent.putExtra("num",1);
                startActivity(intent);

            }
        });

        btnyinshi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String url=eturl.getText().toString();
                Intent intent=new Intent(Intent.ACTION_VIEW, Uri.parse(url));
                startActivity(intent);
            }
        });

        btndail.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String tel="tel:"+ettel.getText().toString();
                Intent intent=new Intent(Intent.ACTION_VIEW,Uri.parse(tel));
                startActivity(intent);
            }
        });
    }
}
